package com.love.marriage.cloud.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.love.marriage.cloud.service.AliyunImageService;
import com.love.marriage.cloud.vo.AudioImageResVo;
import com.love.marriage.cloud.vo.AudioImageVo;
import com.love.marriage.common.interfaces.avoid.LogRestRequest;
import com.love.marriage.common.vo.Result;
import com.love.marriage.common.vo.ResultBoolean;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * description:  用户登录历史表restApi
 * author:       mybatisPlus
 * createDate:   2024-10-12 11:25:06
 * version:      1.0.0
 */
@ApiSort(100)
@Tag(name = "阿里云图片相关接口", description = "阿里云图片相关接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/aliyun/imgae")
public class AliyunImageController {

    private final AliyunImageService aliyunImageService;

    @ApiOperationSupport(order = 10, author = "alex")
    @Operation(summary = "校验图片", description = "校验图片")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = ResultBoolean.class
                    )))
    @PostMapping(value = "/auditImage")
    @Tag(name = "公共", description = "公共接口")
    @LogRestRequest(apiName = "阿里云校验图片(类)")
    public Result<AudioImageResVo> auditImage(@RequestBody AudioImageVo audioImageVo) throws Exception {
        return Result.success(aliyunImageService.auditImage(audioImageVo));
    }

    @ApiOperationSupport(order = 10, author = "alex")
    @Operation(summary = "校验图片", description = "校验图片")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = ResultBoolean.class
                    )))
    @PostMapping(value = "/auditImageFile")
    @Tag(name = "公共", description = "公共接口")
    @LogRestRequest(apiName = "阿里云校验图片(文件)")
    public Result<AudioImageResVo> auditImageFile(@RequestPart(value = "file") MultipartFile file) throws Exception {
        return Result.success(aliyunImageService.auditImageFile(file));
    }
}
